Release 10.1A: OpenEdge Development:
Java Open Clients
Passing a ProDataGraph as INPUT or INPUT-OUTPUT
To pass a ProDataGraph for INPUT or INPUT-OUTPUT to an application service, you must as a minimum, create a ProDataGraph that maps to the corresponding ProDataSet parameter of the application service. While the mechanisms for programming an input ProDataGraph are identical regardless of the type of ProDataSet parameter it maps to, the requirements for preparing the ProDataGraph depend on the ProDataSet parameter passing mode, data type, and requirements of the application service.
![]()
To pass a
ProDataGraphwhen the parameter passing mode of the ProDataSet isINPUT:
- Prepare the ProDataGaph as required. For more information, see the "Preparing an input ProDataGraph" section.
- Pass the ProDataGraph directly as a parameter to the proxy method.
![]()
To pass a
ProDataGraphwhen the parameter passing mode of the ProDataSet isINPUT-OUTPUT:
- Prepare the ProDataGaph as required. For more information, see the "Preparing an input ProDataGraph" section.
- Create a ProDataGraphHolder object that includes a reference to the ProDataGraph. You can set the reference by using the constructor or by using the setProDataGraphValue() method on the holder object after you create it.
- Pass the ProDataGraphHolder as a parameter to the proxy method.
Note: For some application services, especially those that conform to the OERA, you might never have to prepare a- Get the returned ProDataGraph from the ProDataGraphHolder using the
getProDataGraphValue()method on the holder object and access it similar to anOUTPUTparameter. For more information, see the "Passing a ProDataGraph as OUTPUT" section.ProDataGraphparameter with meta data. You might well receive the initialProDataGraphas an application serviceOUTPUTparameter, update theProDataGraphin your Java Open Client, and pass the modifiedProDataGraphback to the application service as anINPUT-OUTPUTparameter without having to touch any meta data. For more information, see the "Updating a ProDataSet" section.Preparing an input ProDataGraph
If the application service defines a DATASET (static ProDataSet) parameter, you must create a ProDataGraph that at least represents an empty ProDataSet and contains the meta data (ProDataGraphMetaData) that describes the temp-tables and data-relations defined for the 4GL static ProDataSet. There must be one
Note: While you must define aProDataObjectMetaDataobject for each temp-table and oneProDataRelationMetaDataobject for eachDATA-RELATIONobject defined by the static ProDataSet. So, the meta data in theProDataGraphmust match the schema of the static ProDataSet in every particular.ProDataGraphwith all the meta data required to map a static ProDataSet schema, you can tell OpenEdge not to send temp-table schema information to the AppServer in order to optimize data transfer over the network. For more information, see thesetNoSchemaMarshal()method in the "ProDataObjectMetaData class" section.If the application service defines a DATASET-HANDLE (dynamic ProDataSet), you can pass a
ProDataGraphwith any or no meta data, including any or noProDataRelationMetaDataobjects. As a minimum, you can pass aProDataGraphwith empty meta data (an emptyProDataGraphMetaDataobject), which produces an Unknown value (?) in the input DATASET-HANDLE. However, in practice, you must pass a ProDataGraph with meta data that represents the ProDataSet schema expected by the application service. So, most of the time, the programming for aProDataGraphthat maps to static or dynamic ProDataSet is identical.For more information on the differences between static and dynamic ProDataSets, see OpenEdge Development: ProDataSets .
For a typical application, the general procedure for preparing a
ProDataGraphfor input is a two step process.
![]()
To prepare a typical
ProDataGraphfor input:Creating and initializing a ProDataGraph object with meta data
You can use a number of approaches for creating and initializing a ProDataGraph with meta data.
These approaches include two main variations:
The following procedure suggests just one such approach starting with the meta data. For information on creating an OpenEdge ProDataGraph from a Java SDO DataGraph, see the appropriate ProDataGraph constructor in the "ProDataGraph class" section.
![]()
To create and initialize a
ProDataGraphwith meta data:
- Create a ProDataGraphMetaData object using the constructor, where
dataSetNameis the 4GL name of the ProDataSet in the application service:
- Create a ProDataObjectMetaData object for each temp-table defined in the corresponding application service ProDataSet using the constructor:
The parameters specify, respectively:
- The number of temp-table fields.
- An indication if there is a BEFORE-TABLE defined for the temp-table (required in order to update the temp-table).
- The 4GL name of the temp-table.
- Any XML namespace (or null).
- Any XML prefix (or null).
For more information, see the "ProDataObjectMetaData class" section.
- For each ProDataObjectMetaData object created in Step 2, add the column meta data to match the schema of a corresponding temp-table field. So, for each field in the temp-table, invoke this ProDataObjectMetaData method:
The parameters specify, respectively:
- The 1-based number of the temp-table field.
- The 4GL field name.
- If an array field, a value greater than 1 indicating the extent.
- A value specified by a class constant defined in
com.progress.open4gl.Parameterthat indicates the 4GL data type of the field. For more information, see the information on specifying data type meta data for temp-tables in Chapter 4, " Passing Parameters."- A 0-based user position order for the field.
- An XML serialization value for later use, currently set to 0.
- An indication if the field is a primary unique index for the temp-table.
For more information on creating table meta data, see the "ProDataObjectMetaData class" section.
- Add each
ProDataObjectMetaDataobject completed in Step 3 to theProDataGraphMetaDataobject created in Step 1 using thisProDataGraphMetaDatamethod:
- For each
DATA-RELATIONobject defined for the ProDataSet in the application service, create a correspondingProDataRelationMetaDataobject using the constructor:
The second constructor allows you to set foreign-primary key relationships for one or more columns between parent and child tables explicitly. The
parentIdxandchildIdxcorrespond to indexes into the list of table names returned by theProDataGraphMetaDatamethod,getTableNames(). You can also set these relationships in the instantiatedProDataRelationMetaDataobject using the overloadedsetColumns()methods.For more information on creating data-relations, see the "ProDataRelationMetaData class" section.
- Add each
ProDataRelationMetaDataobject completed in Step 5 to theProDataGraphMetaDataobject created in Step 1 using thisProDataGraphMetaDatamethod:
- Create the ProDataGraph from the ProDataGraphMetaData object completed in Step 4 and Step 6 using this constructor:
For more information on creating meta data for a
ProDataGraph, see the "ProDataGraphMetaData class" section.Adding data to a ProDataGraph
Once you have the ProDataGraph defined with its meta data, you can create and add the rows to the various tables (ProDataObject lists) and generate all the data-relation references between them to complete the ProDataGraph. You can add data to a
ProDataGraphin different ways. The following procedure assumes that you know the 4GL names of the temp-tables and fields and the field data types in the corresponding ProDataSet.
![]()
To add data to a
ProDataGraph:
- For each row you want to add to a temp-table, create a
ProDataObjectusing thisProDataGraphfactory method, wheretableNameis the temp-table name:
- For each
ProDataObjectthat you create, add the column property data using one of theseProDataObjectmethods, wherenameis the 4GL name for the corresponding temp-table field:
- To set the value of a single-valued property, use this method, where
DataTypeis the full Java classname or intrinsic type name of the property data type andDataTypeNameis a name that closely matches the data type name for the value:
To identify the Java data type or class of the column property that maps to the 4GL data type of the temp-table field, see Table 5–3. For example, the following two methods set values for an int property (mapped to an
INTEGERfield) and a BigDecimal property (mapped to aDECIMALfield):
- To set the value of a many-valued property (which maps to a temp-table array field), use this method, after loading the
java.util.Listobject with the required values:
The values in the List all have the data type of the column property.
- To set the value of a column property in the form of the
java.lang.Objectclass, use this method:
The value in the Object has the data type of the column property or java.util.List if the property is many-valued.
You can also set the values of column properties with overloaded versions of these methods that index into the
ProDataObjectproperty list. For more information on determining the index of a column property and other information about column properties of aProDataObject, see the "Using Java SDO classes to access Property meta data" section.- Add each
ProDataObject,dataObj, filled with data in Step 2 to theProDataGraphusing thisProDataGraphmethod:
This method adds the
ProDataObjectto the collection (ProDataObjectlist) identified by its defined table name. Using anindex, you can insert theProDataObjectat a location in the list. Otherwise, the object is added to the end of the list.- Once all the tables (
ProDataObjectlists) have been populated with rows of data in Step 3, generate the parent-childProDataObjectreferences specified by all theProDataRelationMetaDataobjects contained in theProDataGraphusing the followingProDataGraphmethod:
You can also generate these references one table at a time using overloads of this method. However, this is the most efficient method to generate data-relation references for a fully populated
ProDataGraph.For more information on methods for building ProDataGraphs, see the "ProDataGraph class" section.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |